from bs4 import BeautifulSoup
from util import utils, httpUtil

path = "src/video"
baseuUrl = " https://www.pornhub.com"
videoUrl = baseuUrl+"/video"
videoPageUrl = videoUrl + "?page="

# 获取当前页面中的视频列表
def getCurPageVideoList(url):
    print(url)
    list = []
    # 获取当前页面
    html = utils.getHtmlUtf_8(url)
    # print(html)
    #获取视频列表
    t1 = BeautifulSoup(html, 'html.parser').find_all(name='a',attrs={"class": "img"})
    for t2 in t1:
        url_ = baseuUrl + t2.get("href")
        list.append(url_)
    return list

#批量获取视频地址
def getUrlListFormList(urlList):
    list = []
    for url in urlList:
        getPlayUrlFormPage(url)
        break

# 获取视频播放地址
def getPlayUrlFormPage(url):
    html = utils.getHtmlUtf_8(url)
    print(html)
    t1 = BeautifulSoup(html, 'html.parser').find_all("video")
    print(t1)
    return

if __name__ == "__main__":
    list = getCurPageVideoList(videoUrl)
    #test
    getUrlListFormList(["https://www.pornhub.com/view_video.php?viewkey=ph5bcc50ca085cf"])